/********************************************************************************************************
 * PROGRAM      : GSSGUI
 * DATE - TIME  : 
 * AUTHOR       :  (  )
 * FILENAME     : gssview.h
 * LICENSE      : 
 * COMMENTARY   : 
 ********************************************************************************************************/
#ifndef GSSVIEW_H
#define GSSVIEW_H

#include <QtNetwork/QTcpSocket>
#include <QtNetwork/QHostAddress>
#include <QDataStream>
#include <QButtonGroup>
#include <iostream>
#include "ui_imp/ui_gssui.h"
#include "ui_imp/ui_mnucamcon.h"
#include "ui_imp/ui_mnuservcon.h"
#include "ui_imp/ui_camconmain.h"
#include "ui_imp/ui_camconcams.h"
#include "ui_imp/ui_camconservos.h"
#include "ui_imp/ui_camcontimers.h"
//#include "hpscclient.h"
#include "gssglobals.h"
#include "pstyledbutton.h"
#include "dlgcommsettings.h"
#include "qhkp.h"
#include "frmpower.h"



//#define BUS1 0x01
//#define BUS2 0x02
//#define BUS3 0x04
//#define BUS4 0x08

/**
The GSS UI class

	@author Archimedes Projekt <thelsb@gmail.com>
*/
class HPSCEventThread;
class DlgCamCon;
class DlgServCon;

class GSSView : public QWidget
{
Q_OBJECT
private:
 DlgCommSettings *dlgSerialSettings;
 HPSCEventThread *m_hpscEventThread; 
 Ui::GSSUI ui;
 Ui::mnuCamCon mnuCamCon;
 Ui::mnuServCon mnuServCon;
 Ui::secCamConMain secCamConMain;
 Ui::secCamConServos secCamConServos;
 Ui::secCamConTimers secCamConTimers;
 Ui::secCamConCams secCamConCams;
 DlgCamCon *m_dlgCamCon;
 DlgServCon *m_dlgServCon;
 QButtonGroup m_grpModules,
 		    m_grpCamConMenu,
            m_grpServConMenu;

 quint8 m_activeBus;
 QTcpSocket *m_hkpSocket;
 QString m_hkpHost;
 quint16 m_hkpPort;
 QTimer *m_hkpTimer,
         *m_hkpTimeout;
 bool m_hkpResponded; //true if HP responds to polling
 int m_iRackPowerState; //-1 = Aborted, 1= on 0=off 
       	
///////////////////////////////////
public:
    GSSView( /*quint16 port ,const QHostAddress & address = QHostAddress::LocalHost,*/QWidget *parent = 0);

    ~GSSView();
    void connectToServers();
    void getHosts();
    void initSockets();
    void initControls();
    void setBusStatusLed(QLabel *led,FrmPower::POWER_STAT status);
    signals:
        void sig_hkp(HkpCommand); //emits hackerport port status    
public slots:
    void selectFirmware();
    void selectBatCharge();
    void selectCamCon();
    void selectFlightSim();
    void selectServCon();
    //void releaseButton();
    void debug_int(int val);
    void serialSettigs(MODULE module);
    void releaseButtons();
    void pollHkp();
    void hkpResponse();
    void hkpDisconnected();
    void updateBusStatus(FrmPower::BUS bus, FrmPower::POWER_STAT status);
    
   
};

#endif
